]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Stop using conditional catch statements
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 15 Jul 2018 01:17:42 +0000 (03:17 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 17 Jul 2018 17:02:39 +0000 (17:02 +0000)
It is a mozilla extension that is going away in SpiderMonkey 60.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/151

js/gdm/util.js
js/ui/notificationDaemon.js
js/ui/runDialog.js
js/ui/scripting.js

index 261e1e433672a3531ff973509852c1fa19fcbe1d..75feb77d0d6598698384f5a73f06d6ae11ebe997 100644 (file)
@@ -350,16 +350,19 @@ var ShellUserVerifier = new Lang.Class({
         try {
             this._clearUserVerifier();
             this._userVerifier = client.open_reauthentication_channel_finish(result);
-        } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
-            return;
-        } catch(e if e.matches(Gio.DBusError, Gio.DBusError.ACCESS_DENIED) &&
-                !this._reauthOnly) {
-            // Gdm emits org.freedesktop.DBus.Error.AccessDenied when there is
-            // no session to reauthenticate. Fall back to performing verification
-            // from this login session
-            client.get_user_verifier(this._cancellable, this._userVerifierGot.bind(this));
-            return;
         } catch(e) {
+            if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
+                return;
+            if (e.matches(Gio.DBusError, Gio.DBusError.ACCESS_DENIED) &&
+                !this._reauthOnly) {
+                // Gdm emits org.freedesktop.DBus.Error.AccessDenied when there
+                // is no session to reauthenticate. Fall back to performing
+                // verification from this login session
+                client.get_user_verifier(this._cancellable,
+                                         this._userVerifierGot.bind(this));
+                return;
+            }
+
             this._reportInitError('Failed to open reauthentication channel', e);
             return;
         }
@@ -374,9 +377,9 @@ var ShellUserVerifier = new Lang.Class({
         try {
             this._clearUserVerifier();
             this._userVerifier = client.get_user_verifier_finish(result);
-        } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
-            return;
         } catch(e) {
+            if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
+                return;
             this._reportInitError('Failed to obtain user verifier', e);
             return;
         }
@@ -434,9 +437,9 @@ var ShellUserVerifier = new Lang.Class({
                                                                (obj, result) => {
                try {
                    obj.call_begin_verification_for_user_finish(result);
-               } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
-                   return;
                } catch(e) {
+                   if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
+                       return;
                    this._reportInitError('Failed to start verification for user', e);
                    return;
                }
@@ -449,9 +452,9 @@ var ShellUserVerifier = new Lang.Class({
                                                       (obj, result) => {
                try {
                    obj.call_begin_verification_finish(result);
-               } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
-                   return;
                } catch(e) {
+                   if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
+                       return;
                    this._reportInitError('Failed to start verification', e);
                    return;
                }
index 9f085629f60f01936f149f5755099b4a85823031..2b5a453c7ab5938807ee516dc5a6db4b7822bc6f 100644 (file)
@@ -831,8 +831,10 @@ var GtkNotificationDaemon = new Lang.Class({
                 let source;
                 try {
                     source = this._ensureAppSource(appId);
-                } catch(e if e instanceof InvalidAppError) {
-                    return;
+                } catch(e) {
+                    if (e instanceof InvalidAppError)
+                        return;
+                    throw e;
                 }
 
                 notifications.forEach(([notificationId, notification]) => {
@@ -863,9 +865,12 @@ var GtkNotificationDaemon = new Lang.Class({
         let source;
         try {
             source = this._ensureAppSource(appId);
-        } catch(e if e instanceof InvalidAppError) {
-            invocation.return_dbus_error('org.gtk.Notifications.InvalidApp', 'The app by ID "%s" could not be found'.format(appId));
-            return;
+        } catch(e) {
+            if (e instanceof InvalidAppError) {
+                invocation.return_dbus_error('org.gtk.Notifications.InvalidApp', 'The app by ID "%s" could not be found'.format(appId));
+                return;
+            }
+            throw e;
         }
 
         let timestamp = GLib.DateTime.new_now_local().to_unix();
index 82deab5a3696a9bfc46e1ba2f25a5921494a0c5d..606a683962c39d1adabb99f7f92fae5c9e8b4ffe 100644 (file)
@@ -172,9 +172,10 @@ var RunDialog = new Lang.Class({
                     if (name.slice(0, text.length) == text)
                         results.push(name);
                 }
-            } catch (e if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND) &&
-                           !e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_DIRECTORY))) {
-                log(e);
+            } catch (e) {
+                if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND) &&
+                    !e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_DIRECTORY))
+                    log(e);
             } finally {
                 return results;
             }
index c53083210048a25db44aa0ad754654b6928d2945..c96ebd1f9c2a795d3321f2bc99c53fda7e2d1859 100644 (file)
@@ -216,12 +216,14 @@ function _step(g, finish, onError) {
                          if (onError)
                              onError(err);
                      });
-    } catch (err if err instanceof StopIteration) {
-        if (finish)
-            finish();
     } catch (err) {
-        if (onError)
-            onError(err);
+        if (err instanceof StopIteration) {
+            if (finish)
+                finish();
+        } else {
+            if (onError)
+                onError(err);
+        }
     }
 }